<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>
        画布
    </title>
</head>

<body onload="main()">
    <canvas id="example" width="400" height="400" style="border: 1px solid red;"> canves </canvas>
    <script>
         function main() {
            var canves = document.getElementById("example");

            var ctx = canves.getContext('2d');

            // 设置填充颜色
            ctx.fillStyle = 'rgba(0,0,255,1.0)'
            // 设置填充区域
            ctx.fillRect(0, 0, 400, 390)
        }
    </script>
</body>

</html>